<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5" >

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>发改局</title>

    <!-- Google Font: Source Sans Pro -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome Icons -->
    <link rel="stylesheet" href="../../plugins/fontawesome-free/css/all.min.css">
    <!-- IonIcons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../../dist/css/adminlte.min.css">
    <!-- Ekko Lightbox -->
    <link rel="stylesheet" href="../../plugins/ekko-lightbox/ekko-lightbox.css">

</head>


<body class="hold-transition sidebar-mini">
<div class="wrapper">

    <!-- 主内容容器 -->
    <div class="content-wrapper">
        <!-- 容器头标题 -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0">系统信息系修改</h1>
                    </div>

                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">首页</a></li>
                            <li class="breadcrumb-item active">系统信息系修改</li>
                        </ol>
                    </div>

                </div>

            </div>

        </div>


        <!-- 主题内容正文 -->
        <div class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">


                        <!-- 添加div -->
                        <div class="card card-primary">
                            <!-- 卡片头部 -->
                            <div class="card-header">
                                <h3 class="card-title">系统信息系修改</h3>
                            </div>
                            <!--卡片头部结束 -->
                            <!-- 表单开始 -->
                            <form id="formbody" action="" method="post" enctype="application/x-www-form-urlencoded">
                                <div class="card-body">

                                    <div class="row">
                                        <div class="col-lg-6">

                                            <input type="hidden" value="1" id="id" name="id" />

                                            <div class="form-group">
                                                <label for="copyright"><span style="color: red">*</span>版权信息(<span style="color: red">支持html代码</span>)</label>
                                                <textarea type="text" th:text="${system.copyright}" class="form-control" id="copyright" name="copyright" placeholder="版权信息"></textarea>
                                            </div>

                                            <div class="form-group">
                                                <label for="copyright"><span style="color: red">*</span>备案号(<span style="color: red">支持html代码</span>)</label>
                                                <input type="text" th:value="${system.record}" class="form-control" id="record" name="record" placeholder="备案号" />
                                            </div>

                                            <div class="form-group">
                                                <label for="copyright"><span style="color: red">*</span>营业执照(<span style="color: red">支持html代码</span>)</label>
                                                <input type="text" th:value="${system.businesslicense}" class="form-control" id="businesslicense" name="businesslicense" placeholder="营业执照" />
                                            </div>

                                            <div class="form-group">
                                                <label for="copyright"><span style="color: red">*</span>版本(例:<span style="color: red;">Version 1.0</span>)</label>
                                                <input type="text" th:value="${system.version}" class="form-control" id="version" name="version" placeholder="版本" />
                                            </div>

                                            <div class="form-group">
                                                <label for="copyright"><span style="color: red">*</span>网站标题</label>
                                                <input type="text" th:value="${system.title}" class="form-control" id="title" name="title" placeholder="网站标题" />
                                            </div>

                                            <div class="form-group">
                                                <label for="copyright"><span style="color: red">*</span>网站登录标题</label>
                                                <input type="text" th:value="${system.loginTitle}" class="form-control" id="logintitle" name="logintitle" placeholder="网站登录标题" />
                                            </div>

                                        </div>

                                    </div>

                                </div>

                                <!-- 添加按钮 -->
                                <div class="card-footer">
                                    <button type="button" class="btn btn-primary" id="change_btn">修改</button>
                                </div>

                            </form>
                            <!-- 表单结束 -->
                        </div>
                        <!-- 卡片结束 -->
                    </div>


                </div>

            </div>

        </div>

    </div>


    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.control-sidebar -->

    <!-- 版权信息 -->
    <footer class="main-footer">
        <strong>Copyright &copy; 2021 <a href="http://www.chengzhouyun.com/" target="_blank">ChengZhouYun</a>.</strong> All
        rights reserved.
        <div class="float-right d-none d-sm-inline-block">
            <b>Version</b> 1.0
        </div>
    </footer>
</div>
<!-- ./wrapper -->

<!-- REQUIRED SCRIPTS -->

<!-- jQuery -->
<script src="../../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE -->
<script src="../../dist/js/adminlte.js"></script>

<!-- OPTIONAL SCRIPTS -->
<!--<script src="../../plugins/chart.js/Chart.min.js"></script>-->
<!-- AdminLTE for demo purposes -->
<script src="../../dist/js/demo.js"></script>
<!-- Ekko Lightbox -->
<!--<script src="../../plugins/ekko-lightbox/ekko-lightbox.min.js"></script>-->
<!-- Filterizr-->
<script src="../../plugins/filterizr/jquery.filterizr.min.js"></script>


</body>

<script th:inline="javascript">

    function isEmptyNull(value){
        if (value == undefined || value == null || value =="") {
            return false;
        }
        return true;
    }

    $(function () {
        // 添加企业按钮事件
        $("#change_btn").on("click",function(){

            if(!isEmptyNull($("#copyright").val())){
                alert('请填写版权信息');
                return;
            }

            if(!isEmptyNull($("#record").val())){
                alert('请填写备案号');
                return;
            }
            if(!isEmptyNull($("#businesslicense").val())){
                alert('请填写营业执照');
                return;
            }
            if(!isEmptyNull($("#version").val())){
                alert('请填写网站版本');
                return;
            }
            if(!isEmptyNull($("#title").val())){
                alert('填写网站标题');
                return;
            }
            if(!isEmptyNull($("#logintitle").val())){
                alert('请填网站登录标题');
                return;
            }

            var formdata = new FormData();
            formdata.id = $("#id").val()
            formdata.copyright = $("#copyright").val()
            formdata.record = $("#record").val()
            formdata.businesslicense = $("#businesslicense").val()
            formdata.version = $("#version").val()
            formdata.title = $("#title").val()
            formdata.loginTitle = $("#logintitle").val()

            // 此处使用ajax修改系统信息
            $.ajax({
                url:"/sys/system",
                type:"PUT",
                data: JSON.stringify(formdata),
                contentType: 'application/json',
                dataType:"json",
                success: function(res){
                    if(res.statusCode == 200) {
                        alert(res.message);
                        window.parent.document.location.reload();
                    } else{
                        alert(res.errorMsg);
                    }
                }
            })
        })
    })
</script>

</html>
